﻿<?php
if (!isset($_SESSION["taikhoan"]))
	{
		header("Location: dbcl-dangnhap.php");
	}
	include "connect.php"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form name="f" method="post" action="" onsubmit="">
			<table width="500" align="center" border="0" style="border:1px solid #0066FF" cellspacing="0">
						
					  <tr> 
							<td height="30" colspan="2" align="center" bordercolor="#FFFFFF" background="image/bg_header.gif">
								<span style="font-size:24px; color:#FFFFFF; font-weight:bold;">Thêm Học Kì mới</span></td>
					  </tr>
					  
					  <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="15" width="200" colspan="2"></td>
						 
					  </tr>
						<?php
						     $sql=mysql_query("select max(ma_hknk) from `hocki nienkhoa`");
							 $s=mysql_fetch_row($sql);
							 $ma=$s[0];
							 $hknk=$ma+1;
							 
							 $str=mysql_query("select hocki from `hocki nienkhoa` where ma_hknk='$ma'");
							 $h=mysql_fetch_row($str);
							 $hocki=$h[0];
							 if($hocki==3) $hk=1;
							 else $hk=$hocki+1;
							 
							 $str1=mysql_query("select nienkhoa from `hocki nienkhoa` where ma_hknk='$ma'");
							 $h1=mysql_fetch_row($str1);
							 $nk=$h1[0];
							 
							 
						?>
					  <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="30" style="font-size:18px" width="200">Mã HKNK:</td>
						 <td align="left"><input type="text" name="ma"  size="4"  value="<?php echo $hknk; ?>" class="mau" readonly="" /></td>
					  </tr>
					  
					  <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="30" style="font-size:18px"> Học Kì </td>
						 <td align="left"><input name="hk" type="text" size="4" value="<?php echo $hk; ?>" class="mau" readonly="" /> </td>
					  </tr>
					  
					   <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="30" style="font-size:18px"> Niên Khóa </td>
						 <td align="left"><input name="nk" type="text" value="<?php echo $nk; ?>" /> </td>
					  </tr>
					  
					  <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="15"  colspan="2"></td>
						 
					  </tr>
					  
					  <tr bordercolor="#FFFFFF">
						  <td  align="right" height="30"><input type="submit" value="Lưu Lại" name="luu" /></td>
						  <td align="center"><input type="reset" value="Làm Lại" name="huy" /></td>
					 </tr>
					 <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="15"  colspan="2"></td>
						 
					  </tr>
					
			</table>
</form>
<?php
           if(isset($_POST["luu"]))
				{
				          $hknk=$_POST["ma"];
				          $hk=$_POST["hk"];
						  $nk=$_POST["nk"];
						  $kq=mysql_query(" insert into `hocki nienkhoa` values('$hknk','$hk','$nk' )");
						  echo"<script type='text/javascript'>alert('Them Thanh Cong')</script>";
		                  echo'<meta http-equiv="refresh" content="0;URL=dbcl-capnhat.php?nav=cnhk">';
						  
				}
 ?>		

</body>
</html>

